#pragma once

#include <unordered_map>
#include <list>
#include "refline/WorldRefLineGraph.h"
#include "geom/RoadGeom.h"

namespace rg {

	/**
	* Bind UE assets in the scene with the OpenDRIVE assets backend.
	*/
	class RoadBuilder
	{

	public:
		// Create the UODRefLineComponent instances and attached them individually to AODRoadActor instances
		RoadBuilder(const FWorldEntityAxis& worldEntityAxis, const FWorldEntityManager& worldEntityMgr);

		void BindOrCreate(const std::vector<FWorldRoad::Ptr>& roads, bool reverseAxisFlags[3]);

	private:

		void BindOrCreate(const FWorldRoad::Ptr& road);

	public:
		const FWorldEntityAxis&		_axis;
		const FWorldEntityManager&	_em;
		FWorldRefLineGraph::Ptr		_reflines;

		struct RoadData
		{
			rg::RoadGeometry::Ptr roadGeom;
			std::vector<rg::RoadGeometry::WeakPtr> predecessors;
			std::vector<rg::RoadGeometry::WeakPtr> sucessors;
		};
		std::unordered_map<FWorldRoad*, RoadData> _roadGeometries;
		

	};


}
